﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Security;

namespace OZDoo.Components
{
    class DefaultMembers : IMembers
    {
        /// <summary>
        /// 
        /// </summary>
        public string ApplicationName
        {
            get { return Membership.ApplicationName; }
            set { Membership.ApplicationName = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public bool EnablePasswordReset { get { return Membership.EnablePasswordReset; } }
        
        /// <summary>
        /// 
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public IUser CreateUser(string username, string password)
        {
            IUser user = new DefaultUser(Membership.CreateUser(username, password));
            return user;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public bool DeleteUser(string username)
        {
            return Membership.DeleteUser(username);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public IUser FindUsersByName(string username)
        {
            return null;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IUser GetAllUsers()
        {
            return null;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IUser GetUser()
        {
            return new DefaultUser(Membership.GetUser());
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        public void UpdateUser(IUser user)
        {
            DefaultUser duser = user as DefaultUser;
            if (duser != null)
            {
                Membership.UpdateUser(duser.User);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool ValidateUser(string username, string password)
        {
            return Membership.ValidateUser(username, password);
        }
    }
}
